package ${exportPackage};

import com.github.pagehelper.PageHelper;
import ${servicePackage}.${po.name}Service;
import ${voPackage}.${po.name}ExportVO;
import com.odianyun.project.query.QueryArgs;
import com.odianyun.project.support.data.IDataStorage;
import com.odianyun.project.support.data.expt.IAsyncDataExportAware;
import com.odianyun.project.support.data.impl.DataTaskExportHandler;
import com.odianyun.project.support.data.model.DataExportParam;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;

@Component
public class ${po.name}ExportHandler extends DataTaskExportHandler<${po.name}ExportVO> {
    @Resource
    private IDataStorage dataStorage;
    @Resource
    private IAsyncDataExportAware dataExportAware;
    @Resource
    private ${po.name}Service service;

    @Override
    public List<${po.name}ExportVO> listExportData(int start, int limit, DataExportParam param) {
        QueryArgs args = (QueryArgs) param.getParameters().get("args");
        PageHelper.offsetPage(start, limit, false);

        return service.list(args);
    }

    @Override
    protected IDataStorage getDataStorage() {
        return dataStorage;
    }

    @Override
    public IAsyncDataExportAware getAsyncDataExportAware() {
        return dataExportAware;
    }

    @Override
    public String getExportType() {
        return "${po.uncapName}Export";
    }

}
